home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlibs.zip / STRNEND.ASM < prev    next >
Assembly Source File  |  1993-01-04  |  1KB  |  49 lines

  1. ;       Static Name Aliases
  2. ;
  3.         TITLE   strnend
  4. ;       NAME    strnend.C
  5.  
  6. ;   strnend(src, len)
  7. ;   returns a pointer to just after the end of the string src, which is
  8. ;   terminated by a NUL character, or by exhaustion of the length bound
  9. ;   len.  That is, strnend(s,L)-s = strnlen(s,L).  s+strnlen(s,L) could
  10. ;   of course be used instead, but this is sometimes clearer.
  11.  
  12.         .287
  13. _TEXT   SEGMENT  BYTE PUBLIC 'CODE'
  14. _TEXT   ENDS
  15. _DATA   SEGMENT  WORD PUBLIC 'DATA'
  16. _DATA   ENDS
  17. CONST   SEGMENT  WORD PUBLIC 'CONST'
  18. CONST   ENDS
  19. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  20. _BSS    ENDS
  21. DGROUP  GROUP   CONST,  _BSS,   _DATA
  22.         ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  23. EXTRN   __chkstk:NEAR
  24. _TEXT      SEGMENT
  25.         PUBLIC  _strnend
  26. _strnend        PROC NEAR
  27.         push    bp
  28.         mov     bp,sp
  29.         push    di
  30.  
  31. ;       s = 4
  32. ;       register di = s
  33. ;       n = 6
  34. ;       register cx = n
  35.  
  36.         mov     di,[bp+4]       ;s
  37.         mov     cx,[bp+6]       ;n
  38.         mov     al,0
  39.         repne   scasb
  40.         xchg    ax,di
  41.         pop     di
  42.         mov     sp,bp
  43.         pop     bp
  44.         ret
  45.  
  46. _strnend        ENDP
  47. _TEXT   ENDS
  48. END
  49.